﻿// *****************************************************************
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
// *****************************************************************

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Bio.TestAutomation.Util;
using Bio.Util.Logging;
using Bio.Distributions;
namespace Bio.TestAutomation.Distributions
{
    /// <summary>
    /// Bvt Test Cases For BooleanStatistics Class
    /// </summary>
    [TestClass]
    public class BooleanStatisticsBvtTestCases
    {
        #region Constructor

        /// <summary>
        /// Static constructor to open log and make other settings needed for test
        /// </summary>
        static BooleanStatisticsBvtTestCases()
        {
            Trace.Set(Trace.SeqWarnings);
            if (!ApplicationLog.Ready)
            {
                ApplicationLog.Open("bio.automation.log");
            }
        }

        #endregion Constructor

        #region BooleanStatistics Bvt Test Cases

        /// <summary>
        /// validates the GetMissingInstance property
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateBooleanStatisticsGetMissingInstance()
        {
            BooleanStatistics boolStat = BooleanStatistics.GetMissingInstance;
            Assert.IsTrue(boolStat.IsMissing());
        }

        /// <summary>
        /// validates the Equals method
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateBooleanStatisticsEquals()
        {
            SufficientStatistics suffStat = BooleanStatistics.GetInstance(false);
            BooleanStatistics boolStat = BooleanStatistics.GetMissingInstance;
            Assert.IsFalse(boolStat.Equals(suffStat));

            suffStat = (SufficientStatistics)boolStat;
            Assert.IsTrue(boolStat.Equals(suffStat));

            boolStat = BooleanStatistics.GetInstance(true);
            suffStat = (SufficientStatistics)boolStat;
            Assert.IsTrue(boolStat.Equals(suffStat));

            boolStat = BooleanStatistics.GetInstance(false);
            suffStat = (SufficientStatistics)boolStat;
            Assert.IsTrue(boolStat.Equals(suffStat));

            object suffStatObj = (object)boolStat;
            Assert.IsTrue(boolStat.Equals(suffStat));
        }

        /// <summary>
        /// validates the TryParse method
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateBooleanStatisticsTryParse()
        {
            SufficientStatistics result = null;
            BooleanStatistics boolStat = BooleanStatistics.GetInstance(true);
            Assert.IsTrue(BooleanStatistics.TryParse("true", out result));
            Assert.IsTrue(boolStat.Equals(result));
        }

        /// <summary>
        /// validates the constants of BooleanStatistics class
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateBooleanStatisticsConstants()
        {
            Assert.AreEqual(-1, BooleanStatistics.Missing);
            Assert.AreEqual(0, BooleanStatistics.False);
            Assert.AreEqual(1, BooleanStatistics.True);
        }


        /// <summary>
        /// validates the ToString method
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateBooleanStatisticsToString()
        {
            BooleanStatistics boolStat1 = BooleanStatistics.GetInstance(true);
            BooleanStatistics boolStat2 = BooleanStatistics.GetMissingInstance;
            Assert.AreEqual("1", boolStat1.ToString());
            Assert.AreEqual("-1", boolStat2.ToString());
        }

        #endregion BooleanStatistics Bvt Test Cases
    }
}
